<div class="bs-callout bs-callout-info">
    <h4>Edit services</h4>
    <p><a href="<?php echo base_url()?>admin/services">+ Back</a></p>
</div>

<form class="form-horizontal" role="form" method="POST">    
    <div class="form-group">
        <label for="parentId" class="col-sm-2 control-label">Parent</label>
        <div class="col-sm-4">
            <select id="parentId" name="parentId" class="form-control">
                <option value="0">Parent</option>
                <?php
                    foreach($parents as $key=>$value){
                ?>
                <option value="<?php echo $value['servicesId']?>" <?php if($value['servicesId'] == $data['parentId']) echo 'selected'?> ><?php echo $value['title']?></option>
                <?php
                    }
                ?>
            </select>
        </div>
        <label for="languageCode" class="col-sm-2 control-label">Language</label>
        <div class="col-sm-4">
            <select id="languageCode" name="languageCode" class="form-control" onchange = "redirectlink('<?php echo base_url()."admin/services/editLanguage/".$data['servicesId'].'/';?>'+ this.value);" >
                <?php
                    foreach($languages as $key=>$value){
                ?>
                <option value="<?php echo $value['languageCode']?>" <?php if($value['languageCode'] == $data['languageCode']) echo 'selected';?> ><?php echo $value['languageName']?></option>
                <?php
                    }
                ?>
            </select>
        </div>
    </div>
    
    <div class="form-group">
        <label for="title" class="col-sm-2 control-label">Title</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="title" placeholder="Title" name="title" required="true" value="<?php echo $data['title'];?>" />
        </div>
    </div>
    
    <div class="form-group">
        <label for="slug" class="col-sm-2 control-label">Slug</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="slug" placeholder="Slug" name="slug" required="true" value="<?php echo $data['slug'];?>" />
        </div>
    </div>
    
    <div class="form-group">
        <label for="header" class="col-sm-2 control-label">Header</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="header" placeholder="Header" name="header" required="true" value="<?php echo $data['header'];?>" />
        </div>
    </div>
    
    <div class="form-group">
        <label for="image" class="col-sm-2 control-label">Image</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="image" placeholder="Image" name="image" required="true" value="<?php echo $data['image'];?>" />
        </div>
        <div class="col-sm-2">
            <input type="button" id="btnSelectImg" class="btn btn-primary" value="Browse server" />
        </div>
    </div>
    
    <div class="form-group">
        <label for="description" class="col-sm-2 control-label">Description</label>
        <div class="col-sm-10">
            <textarea class="form-control" id="description" placeholder="Description" name="description" required="true"><?php echo $data['description'];?></textarea>
        </div>
    </div>
    
    <div class="form-group">
        <label for="detail" class="col-sm-2 control-label">Detail</label>
        <div class="col-sm-10">
            <textarea class="form-control" id="detail" placeholder="Detail" name="detail" required="true"><?php echo $data['detail'];?></textarea>
        </div>
    </div>
    
    <div class="form-group">
        <label for="number" class="col-sm-2 control-label">Number</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="number" placeholder="Number" name="number" required="true" value="<?php echo $data['number'];?>" />
        </div>
    </div>
    
    
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">Save</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    $(document).ready(function () {
        $("#btnSelectImg").click(function () {
            var finder = new CKFinder();
            finder.selectActionFunction = function (fileUrl) {
                $('#image').val(fileUrl);
            };
            finder.popup();
        });
    });
 </script>
 
<script type="text/javascript">
function redirectlink(url){
    window.location.href=url;
}
$(function() {				    				    
    var editor = CKEDITOR.replace('detail',
    {
        filebrowserBrowseUrl : '<?php echo base_url()."library/ckfinder/ckfinder.html"; ?>',
        filebrowserImageBrowseUrl : '<?php echo base_url()."library/ckfinder/ckfinder.html?Type=Images";?>',
        filebrowserFlashBrowseUrl : '<?php echo base_url()."library/ckfinder/ckfinder.html?Type=Flash" ?>',
        filebrowserUploadUrl : '<?php echo base_url()."library/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files"?>',
        filebrowserImageUploadUrl : '<?php echo base_url()."library/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images";?>',
        filebrowserFlashUploadUrl : '<?php echo base_url()."ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash";?>',
        filebrowserWindowWidth : '800',
        filebrowserWindowHeight : '480'
    });
    CKFinder.setupCKEditor( editor, "<?php echo base_url().'library/ckfinder/'?>" );
})
</script>
 